def is_odd(n):
    return n % 2 == 1


L = filter(is_odd, [1, 2, 4, 5])
print(list(L))

#用lambda匿名函数格式实现过滤偶数
L=filter(lambda n:n%2==1, [1, 2, 4, 5])
print(list(L))

##将空字符串删掉
def not_empty(s):
  return s and s.strip()

L=filter(not_empty, ['A', '', 'B', None, 'C', '  '])
print(list(L))

#匿名函数实现
L=filter(lambda s:(s and s.strip()), ['A', '', 'B', None, 'C', '  '])